﻿@model dynamic
@using Newtouch.Infrastructure
@{
    ViewBag.Title = "入区登记";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<script src="@SiteUrl.GetStaticResourceScriptUrl("~/js/wdtree/tree.js")"></script>
<link href="@SiteUrl.GetStaticResourceScriptUrl("~/js/wdtree/tree.css")" rel="stylesheet" />
<script src="~/Content/js/BootstrapMenu.min.js"></script>
<style type="text/css">
    .dv-body {
        /*background-color: #00a0e9;*/
        width: 100%;
    }

    .dv-left {
        float: left;
        width: 120px;
        height:300px;
        background-color: white;
    }

    .dv-right {
        float: left;
        margin-left: 5px;
    }

    .dv-right-pat {
        background-color: white;
        width: 100%;
        display: inline-block;
    }

    .nav-right {
        position: absolute;
        top: 0;
        right: 0;
        width: 35px;
        font-size: 1.2rem;
        z-index: 101;
        cursor: pointer;
        background-color: #ffffff;
    }

        .nav-right .nav li {
            border: 1px solid #ddd;
            border-radius: 5px 0 0 5px;
            padding: 10px 5px;
            margin: 0 auto;
            writing-mode: vertical-lr;
            writing-mode: tb-rl;
        }

            .nav-right .nav li:hover {
                border: 1px solid #00a0e9;
                background-color: #00a0e9;
                color: #ffffff;
            }

        .nav-right .active {
            margin-left: -5px;
            background-color: #00a0e9;
            color: #ffffff;
            border-color: #00a0e9;
        }

    .dv-right-pat .ul_patInfo {
        position: relative;
        width: 100%;
        height: 100%;
        list-style: none;
        padding: 0;
        margin: 0;
        z-index: 100;
    }

        .dv-right-pat .ul_patInfo li {
            float: left;
            height: 30px;
            width: 182px;
            margin: 5px;
            border: 1px solid #B0E2FF;
            cursor: move;
            display: inline-block;
            vertical-align: middle;
            background-color: #B0E2FF;
            border-radius: 5px;
            -webkit-box-shadow: #666 2px 2px 3px;
            -moz-box-shadow: #666 2px 2px 3px;
            box-shadow: #666 2px 2px 3px;
        }

            .dv-right-pat .ul_patInfo li:hover {
                color: #ffffff;
            }

            .dv-right-pat .ul_patInfo li:hover {
                border: 1px solid #00a0e9;
                background-color: #00a0e9;
            }

    .li-sex {
        line-height: 30px;
        margin-left: 10px;
    }

    .dv-right-pat li span {
        margin: 0 5px;
    }

    .dv-mid-info {
        height: 22px;
        font-size: 15px;
    }

    .tab-mid {
        margin-top: 8px;
    }

    .td-info {
        color: red;
    }

    .td-select {
        height: 16px;
        font-size: 13px;
    }

    .dv-right-bed {
        background-color: white;
        width: 100%;
        display: inline-block;
        padding: 5px;
    }

        .dv-right-bed ul {
            position: relative;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            list-style: none;
            padding: 0;
            margin: 0;
            overflow-y: auto;
            z-index: 888;
        }

        .dv-right-bed li {
            float: left;
            height: 100px;
            width: 170px;
            margin: 10px;
            border: 1px solid #B0E2FF;
            background-color: #B0E2FF;
            cursor: move;
            display: inline-block;
            vertical-align: middle;
            border-radius: 5px 5px 0 0;
            -webkit-box-shadow: #666 2px 2px 3px;
            -moz-box-shadow: #666 2px 2px 3px;
            box-shadow: #666 2px 2px 3px;
        }

            .dv-right-bed li .patxb {
                font-size: 1.5rem;
                float: right;
                margin: 7px 2px 5px 5px;
                color: #00a0e9;
            }

            .dv-right-bed li .patType {
                vertical-align: -60%;
                margin-left: 5px;
            }

            .dv-right-bed li .patCnt {
                vertical-align: -60%;
                margin: 9px;
                float: right;
                color: red;
            }


            .dv-right-bed li:hover {
                border: 1px solid #00a0e9;
                background-color: #00a0e9;
            }



    .dv-bed {
        height: 25%;
        line-height: 100%;
        padding: 0 1px;
        background-color: #ffffff;
    }

    .dv-bedpat {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .dv-bed .border {
        border: 1px solid #ccc;
        margin-top: 2px;
        margin-left: 2px;
        padding: 2px;
        font-size: 1.8rem;
    }

    .dv-bed .dv-sp {
        margin-left: 15px;
        height: 100%;
        float: none;
        line-height: 100%;
        display: inline-block;
        vertical-align: 25%;
    }

    .dv-right-bed .dv-bedNo {
        background-color: inherit;
        text-align: center;
    }

        .dv-right-bed .dv-bedNo:hover {
            color: #ffffff;
        }
</style>
<div class="dv-body">
    <div class="dv-left" id="BQtree">
        @Html.Partial("_WardTreeForm")
    </div>
    <div class="dv-right">
        <div class="dv-right-pat">
            <div class="nav-right">
                <ul class="nav">
                    <li role="presentation" class="active" id="li_new">新入区</li>
                    <li role="presentation" id="li_turn">转区</li>
                </ul>
            </div>
            <ul class="ul_patInfo" id="ul_turn" style="display:none;"></ul>
            <ul class="ul_patInfo" id="ul_new"></ul>
        </div>
        <div class="panel panel-success"></div>
        <div class="dv-mid-info" style="border-radius:10px">
            <table>
                <tr>
                    <td class="panel-title">&nbsp;&nbsp;患者信息：</td>
                    <td class="panel-title">&nbsp;&nbsp;姓名：</td>
                    <td class="td-info panel-title" id="labName"></td>
                    <td>&nbsp;&nbsp;性别：</td>
                    <td class="td-info" id="labsex"></td>
                    <td>&nbsp;&nbsp;住院号：</td>
                    <td class="td-info" id="labzyh"></td>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;床位显示：</td>
                    <td>
                        <label><input type="radio" name="optionsRadios" class="optionsRadios formClearIgnore" checked value="0" />全部</label>
                        &nbsp;
                        <label><input type="radio" id="radioTreating" name="optionsRadios" class="optionsRadios formClearIgnore" value="1" />空床</label>

                    </td>
                </tr>
            </table>
        </div>
        <div class="panel-body dv-right-bed">
            <ul id="ul_bed"></ul>
        </div>
        @*<div id="bqc" style="display:none"></div>*@
    </div>
</div>

<script type="text/javascript">
    var aabb="";
    var eleDv;//
    var zyh;//住院号
    var bedCode;//床位代码
    var bqdm = $("#bqc").val();//病区代码
    var bedInfoStr = "";
    var qqlx = 0;//0新入区，1转区
    var ysgh;
    var ysmc;
    var lastcwCode = null; //转区-前一个床位
    var DeptCode = null; //当前科室
    $(document).ready(function () {

        DefaultCheck();
    });
    //默认选中根节点.
    function DefaultCheck() {
        var firstid = $("div[id^='wardTree_']:first").attr("id").replace("wardTree_", "");//根节点病区代码
        //var firstid = $("div[id^='BQtree_']:first").attr("id").replace("BQtree_", "");//根节点病区代码
        //var firstid = "nkbq01";//根节点病区代码
        
        //var addstyleid = 'BQtree_' + firstid;
        var addstyleid = 'wardTree_' + firstid;
        var item = new Object();
        item.id = firstid;
        $("#" + addstyleid + "").addClass('bbit-tree-selected');//增加选中样式
        wardTree_onnodeclick(item);
        //$("div[id^='wardTree_']").each(function () {
        //    var tpath = $(this).attr("tpath");
        //    if (tpath == 0) {
        //        var id = $(this).attr("id").replace("wardTree_", "");
        //        var $id = $(this);
        //        $id.addClass('bbit-tree-selected');
        //        $("#li_turn").removeClass('active');
        //        $("#li_new").addClass('active');
        //        qqlx = "0";
        //        getPatInitList(id);
        //        getBedInitList(id, 0);
        //        bqdm = id;
        //    }
        //});
    }


    //$("#BQtree").treeview({
    //    height: $(window).height() - 175,
    //    slimscroll: false,
    //    showcheck: false,
    //    url: "/NurseManage/EntryRegistration/TreeViewdata",
    //    onnodeclick: function (item) {
    //        if (item.value && item.Ex1 == "c") {
    //            checkArray = [];
    //            bqdm = JSON.stringify(item.id);
    //            aabb = JSON.stringify(item.id);
    //            $("#bqc").text(aabb);
    //            //zyh = item.val;
    //            //$('#gridList').jqGrid('setGridParam', {
    //            //    postData: { patInfo: item.value, keyword: keyword, kssj: kssj, jssj: jssj }
    //            //}).trigger("reloadGrid");
    //        }

    //    }

    //});
    
    $("#ul_bed").on("click", "li", function () {
        
        //选中变色
        $(this).siblings().css("background-color", "#AFEEEE").css("border", "1px solid #AFEEEE");
        //$("#ul_bed li,#ul_new li").css("background-color", "#bfbdbd").css("border", "1px solid #bfbdbd");
        $(this).css("background-color", "#00a0e9").css("border", "1px solid #00a0e9");
        $("#labName").html("");
        $("#labsex").html("");
        $("#labzyh").html("");
        var patInfo = $(this).find("input[name='hid_patInfo']").val();
        var obj = $.parseJSON(patInfo);
        $("#labName").html((obj.name == "null") ? "" : obj.name);
        $("#labsex").html((obj.xb == "null") ? "" : (obj.xb == "1" ? "男" : (obj.xb == "2" ? "女" : (obj.xb == "3" ? "未知" : ""))));
        $("#labzyh").html((obj.zyh == "null") ? "" : obj.zyh);
        
    })
    $("#li_new").on("click",function () {
        $("#li_turn").removeClass('active');
        $("#li_new").addClass('active');
        qqlx = "0";
        getPatInitList(bqdm);
        //InitTZ();
    })
    $("#li_turn").on("click",function () {
        $("#li_new").removeClass('active');
        $("#li_turn").addClass('active');
        qqlx = "1";
        getPatInitList(bqdm);
        //InitTZ();
    })
    //初始化患者列表
    function getPatInitList(bqdm)
    {
        $.loading(true, "sss");

        $.najax({
            type: "GET",
            url: "/EntryRegistration/GetPatList",
            data: { bqdm: bqdm, qqlx: qqlx },
            dataType: "json",
            async: true,
            loadingtext: "数据查询中，请稍后...",
            success: function (ajaxresp) {
                $("#ul_new").html("");
                if (ajaxresp.rows.length > 0) {
                    $.each(ajaxresp.rows, function (n, item) {
                        var hzxb = "";
                        if (item.xb == "男") {
                            //1男 2女 3混
                            hzxb = "fa-mars";
                        }
                        if (item.xb == "女") {
                            hzxb = "fa-venus";
                        }

                        var nls = "";
                        if (item.nlshow == "0" || item.nlshow == null || item.nlshow == "") {//数据为0表示nlshow为空
                            nls = item.nl + "岁";
                        } else {
                            nls = item.nlshow;
                        }
                        var title = "住院号：" + item.zyh + "; 年龄：" + nls + "; 性别：" + item.xb + "; 入院时间：" + item.ryrq + "; 入院诊断：" + item.zd + "";
                        var hidInfo = "{\"zyh\":\"" + item.zyh + "\",\"name\":\"" + item.xm + "\",\"xb\":\"" + item.xb + "\",\"type\":\"" + item.brxzmc + "\",\"ysgh\":\"" + item.ysgh + "\",\"ysmc\":\"" + item.ysmc + "\",\"lastcwCode\":\"" + item.lastcwCode + "\",\"DeptCode\":\"" + item.DeptCode + "\"}";
                        $("#ul_new").append("<li draggable=\"true\" title=\"" + title + "\"><i class=\"fa " + hzxb + " li-sex\" aria-hidden=\"true\"></i><span>" + item.xm + "</span><span>" + nls + "</span><span>" + item.brxzmc + "</span><input type=\"hidden\" name=\"hid_patInfo\" value='" + hidInfo + "' /></li>");
                    })
                    InitTZ(false);
                }
            }
        });
    }
    //初始化病床列表
    function getBedInitList(bqdm, cwlb) {
       
        var strdata = "bqdm="+bqdm+"&cwlb=" + cwlb;
        $.najax({
            type: "GET",
            url: "/EntryRegistration/GetBedList",
            dataType: "json",
            data:strdata,
            async: true,
            loadingtext: "数据查询中，请稍后...",
            success: function (ajaxresp) {
                $("#ul_bed").html("");
                if (ajaxresp.rows.length > 0) {
                    bedInfoStr = "";
                    $.each(ajaxresp.rows, function (n, item) {
                        var hidInfo = "{\"zyh\":\"" + item.zyh + "\",\"name\":\"" + item.xm + "\",\"xb\":\"" + item.xb + "\",\"doctor\":\"" + item.ysmc + "\",\"cwCode\":\"" + item.cwCode + "\",\"type\":\"" + item.zyh + "\",\"bedNo\":\"" + item.cwmc + "\"}";
                        var hzxb = "";
                        bedInfoStr += '"' + item.cwCode + '"' + ':[{"cwCode":"' + item.cwCode + '","zyh":"' + item.zyh + '","cwsystu":"' + item.cwsystu + '"}],';
                        //床位是否占用
                        if (item.sfzy) {

                            if (item.xb == "1") {
                                //1男 2女 3混
                                hzxb = "fa-mars";
                                color = "#00a0e9";
                            }
                            if (item.xb == "2") {
                                hzxb = "fa-venus";
                                color = "#ef89d7";
                            }

                            if (item.cwsystu == '@((int)EnumCwjlzt.Zq)') {
                                $("#ul_bed").append("<li bedNo=\"" + item.bfNo + "-" + item.cwmc + "\" cwCode=\"" + item.cwCode + "\"  noPatient=\"false\" menuclick=\"false\" draggable=\"true\">\<div class=\"dv-bed dv-bedNo\"><span class=\"dv-sp\" style=\"vertical-align: -50%;\">" + item.bfNo + "-" + item.cwmc + "</span></div><div class=\"dv-bed dv-bedpat\"><i class=\"fa fa-bed border\" aria-hidden=\"true\" style=\"color:red\"></i><span class=\"dv-sp patName\">" + item.xm + "</span><i class=\"fa " + hzxb + " patxb\" aria-hidden=\"true\" style=\"color:#ef89d7\"></i></div><div class=\"dv-bed\"><i class=\"fa fa-user-md\" aria-hidden=\"true\" style=\"font-size:1.8rem;margin:7px 8px 5px 8px; color:" + color+" \"></i><span class=\"dv-sp patDoctor\" style=\"color:red;font-weight:bold;\">" + "转区待入" + "</span></div><div class=\"dv-bed\"><span class=\"dv-sp patType\">" + item.brxzmc + "</span></div><input type=\"hidden\" name=\"hid_patInfo\" value='" + hidInfo + "' /></li>");
                            }
                            else {
                                $("#ul_bed").append("<li bedNo=\"" + item.bfNo + "-" + item.cwmc + "\" cwCode=\"" + item.cwCode + "\"  noPatient=\"false\" menuclick=\"true\" draggable=\"true\">\<div class=\"dv-bed dv-bedNo\"><span class=\"dv-sp\" style=\"vertical-align: -50%;\">" + item.bfNo + "-" + item.cwmc + "</span></div><div class=\"dv-bed dv-bedpat\"><i class=\"fa fa-bed border\" aria-hidden=\"true\" style=\"color:#6cf535\"></i><span class=\"dv-sp patName\">" + item.xm + "</span><i class=\"fa " + hzxb + " patxb\" aria-hidden=\"true\" style=\"color:" + color+"\"></i></div><div class=\"dv-bed\"><i class=\"fa fa-user-md\" aria-hidden=\"true\" style=\"font-size:1.8rem;margin:7px 8px 5px 8px; color:#00a0e9\"></i><span class=\"dv-sp patDoctor\">" + item.ysmc + "</span></div><div class=\"dv-bed\"><span class=\"dv-sp patType\">" + item.brxzmc + "</span></div><input type=\"hidden\" name=\"hid_patInfo\" value='" + hidInfo + "' /></li>");
                            }
                        }
                        else {
                            if (item.cwlx == "1") {
                                //1男 2女 3混
                                cwlx = "男";
                            }
                            if (item.cwlx == "2") {
                                cwlx = "女";
                            }
                            if (item.cwlx == "3") {
                                cwlx = "混";
                            }
                            $("#ul_bed").append("<li bedNo=\"" + item.bfNo + "-" + item.cwmc + "\" cwCode=\"" + item.cwCode + "\" noPatient=\"true\" menuclick=\"true\"  patXb=\"" + cwlx + "\">\<div class=\"dv-bed dv-bedNo\"><span class=\"dv-sp\" style=\"vertical-align: -50%;\">" + item.bfNo + "-" + item.cwmc + "</span></div><div class=\"dv-bed \"><i class=\"fa fa-bed border\" aria-hidden=\"true\" style=\"font-size:1.8rem; color:#ffffff\"></i><span class=\"dv-sp patName\">空床(" + cwlx + ")</span><i class=\"fa  patxb\" aria-hidden=\"true\" style=\"color:#ffffff\"></i></div><div class=\"dv-bed\"><i class=\"fa fa-user-md\" aria-hidden=\"true\" style=\"font-size:1.8rem;margin:7px 8px 5px 8px; color:#00a0e9\"></i><span class=\"dv-sp patDoctor\"></span></div><div class=\"dv-bed\"><span class=\"dv-sp patType\"></span></div><input type=\"hidden\" name=\"hid_patInfo\" value='" + hidInfo + "' /></li>");
                        }

                    })
                    InitTZ(true);
                }
            }
        });
    }
    //
    $("input[name='optionsRadios']").click(function () {
        if (bqdm != null) {

        }
        getBedInitList(bqdm, $(this).val());
    });

    //计算宽高
    function CalculationHW() {
        $(".dv-body").height($(window).height());
        $(".dv-body").width($(window).width());
        var rightWidth = $(".Newtouch_iframe", parent.document).width() - $(".dv-left").width() - 5;
        $(".dv-right").width(rightWidth-20);
        $(".dv-right-pat").height($(".Newtouch_iframe", parent.document).height() / 2 - 120);
        $(".dv-right-bed").height($(".Newtouch_iframe", parent.document).height() - $(".dv-right-pat").height() - 85);
    }
    CalculationHW();
    //$(function () {
    //    $(window).resize(function () {//浏览器窗口调整大小时重新计算宽高
    //        CalculationHW();
    //    });
    //    $('#gridBqList').jqGrid("clearGridData");
    //    $('#gridBqList').newtouchLocalDataGrid(null, bqList);
    //    $(".nav-right li").click(function () {
    //        if (!$(this).hasClass("active")) {
    //            var id = $(this)[0].id.replace("li_", "");
    //            id = "ul_" + id;
    //            $(".ul_patInfo").hide(300);
    //            $("#" + id).show(400);
    //            $(".nav-right li").removeClass("active");
    //            $(this).addClass("active");
    //        }
    //    });
    //});

    //拖拽和右键菜单事件加载
    function InitTZ(isBed)
    {
        var eleDvTarget = $(".dv-right-bed li[noPatient=true]");
        var eleDvSource = $(".dv-right-pat li");
        var eleDvZcSource = $(".dv-right-bed li[noPatient=false]");
        var eleDv = null;
        var eleBeDv = null;
        for (var i = 0; i < $(".dv-right-pat li").length; i++) {
            eleDvSource[i].onselectstart = function () {
                return false;
            };
            eleDvSource[i].ondragstart = function (ev) {
                eleDv = ev.target;
                ev.dataTransfer.effectAllowed = "move";
                ev.dataTransfer.setData("text", ev.target.innerHTML);
                //var node = createDragImage($(this), 0, 0);
                //ev.dataTransfer.setDragImage(node, 0, 0);
                //ev.dataTransfer.setDragImage(ev.target, 0, 0);

                return true;
            };
            eleDvSource[i].ondragend = function (ev) {
                ev.dataTransfer.clearData("text");
                return false;
            };
        }
        for (var i = 0; i < eleDvZcSource.length; i++) {
            eleDvZcSource[i].onselectstart = function () {
                return false;
            };
            eleDvZcSource[i].ondragstart = function (ev) {
                ev.dataTransfer.effectAllowed = "move";
                ev.dataTransfer.setData("text", ev.target.innerHTML);
                //ev.dataTransfer.setDragImage(ev.target, 0, 0);
                eleDv = ev.target;//转床时
                eleBeDv = ev.target;
                return true;
            };
            eleDvZcSource[i].ondragend = function (ev) {
                ev.dataTransfer.clearData("text");
                return false;
            };
        }
        for (var i = 0; i < eleDvTarget.length; i++) {
            currentEv = null;
            eleDvTarget[i].ondragover = function (ev) {
                ev.preventDefault();
                return true;
            }
            eleDvTarget[i].ondragenter = function (ev) {
                this.style.color = "#ffffff";
                return true;
            };
            eleDvTarget[i].ondrop = function (ev) {
                currentEv = ev.currentTarget;

                var itemStr = $(eleDv).find("[name=hid_patInfo]").val();
                var item = JSON.parse(itemStr);
                zyh = item.zyh;
                ysgh = item.ysgh;
                ysmc = (item.ysmc == "null" ? "" : item.ysmc);
                var itemBedStr = $(this).find("[name=hid_patInfo]").val();
                var itemBed = JSON.parse(itemBedStr);
                bedCode = itemBed.cwCode;
                if ($(eleBeDv).attr("noPatient") === "false") {
                    TransferBed(eleBeDv);
                    eleBeDv = null;
                } else {

                    if (item.xb !="null" && $(this).attr("patXb") != "混" && $(this).attr("patXb") != item.xb) {
                        $.modalAlert("该患者不能入住\"" + $(this).attr("patXb") + "\"病床", 'warning');
                        return;
                    }
                    lastcwCode = item.lastcwCode;
                    DeptCode = item.DeptCode;
                    OpenRqdjForm();
                }
                this.style.color = "#000000";
                return false;
            }
        }
        var currentEv = null;

        //右键菜单
        //var beds = {
        //    'A02-1床': { bedNo: 'First row', description: 'Lorem ipsum dolor sit amet' },
        //    '1001-2001B': { bedNo: 'Second row', description: 'Nemo enim ipsam voluptatem quia voluptas' },
        //    '1001-2002A': { bedNo: 'Third row', description: 'Ut enim ad minima veniam' }
        //};


        //bedInfoStr='{"0001":[{"cwCode":"0001","zyh":"00044"}],"000":[{"cwCode":"000","zyh":"00044"}]}';
        if (isBed) {
            bedInfoStr = '{' + bedInfoStr.substring(0, bedInfoStr.length - 1) + '}';
        }
        var bedInfoJson = JSON.parse(bedInfoStr);
        var menuNo = new BootstrapMenu('.dv-right-bed li[noPatient="true"][menuclick="true"]', {
            fetchElementData: function ($rowElem) {
                var rowId = $($rowElem).attr('cwcode');
                return bedInfoJson[rowId];
            },
            actions: [{
                name: '维护床位费',
                onClick: function (row) {

                    $.modalOpen({
                        id: "BedBindingCostForm",
                        title: "维护床位费",
                        url: "/NurseManage/WardMaintenance/BedBindingCostForm?bedCode=" + row[0].cwCode + "&zyh=" + $("#labzyh").html(),
                        width: "900px",
                        height: "500px",
                        callBack: function (iframeId) {
                            top.frames[iframeId].SavaBindItems();
                            $.loading(false);
                            $.modalClose("BedBindingCostForm");
                        }
                    });
                }
            }]
        });
        var menu = new BootstrapMenu('.dv-right-bed li[noPatient="false"][menuclick="true"]', {
            fetchElementData: function ($rowElem) {
                var rowId = $($rowElem).attr('cwcode');
                return bedInfoJson[rowId];
            },
            actions: [{
                name: '维护床位费',
                onClick: function (row) {
                    
                    $.modalOpen({
                        id: "BedBindingCostForm",
                        title: "维护床位费",
                        url: "/NurseManage/WardMaintenance/BedBindingCostForm?bedCode=" + row[0].cwCode + "&zyh=" + $("#labzyh").html(),
                        width: "900px",
                        height: "500px",
                        callBack: function (iframeId) {
                            top.frames[iframeId].SavaBindItems();
                            $.loading(false);
                            $.modalClose("BedBindingCostForm");
                        }
                    });
                }
            },  {
                name: '维护入区登记信息',
                onClick: function (row) {
                    $.modalOpen({
                        id: "updatWZForm",
                        title: "维护入区登记信息",
                        url: "/NurseManage/EntryRegistration/EntryAreaFrom?ysgh=" + ysgh + "&ysmc=" + ysmc + "&zyh=" + row[0].zyh+"&type="+"update",
                        width: "500px",
                        height: "480px",
                        callBack: function (iframeId) {
                            top.frames[iframeId].SavaBindWzjb();
                            $.loading(false);
                            $.modalClose("updatWZForm");

                        }
                    });
                }
            },{
                name: '绑定患者所属医生',
                onClick: function (row) {
                    $.modalOpen({
                        id: "DoctorBindingForm",
                        title: "绑定患者所属医生",
                        url: "/NurseManage/WardMaintenance/DoctorBindingForm?zyh=" + row[0].zyh,
                        width: "500px",
                        height: "480px",
                        callBack: function (iframeId) {
                            top.frames[iframeId].SavaBindDocs();
                            $.loading(false);
                            $.modalClose("DoctorBindingForm");
                        }
                    });
                }
            }, {
                name: '患者出区',
                onClick: function (row) {
                    $.modalConfirm("确定出区？", function (flag) {
                        if (flag) {
                            $.modalOpen({
                                id: "OutAreaForm",
                                title: "患者出区",
                                url: "/NurseManage/WardMaintenance/OutAreaForm?zyh=" + row[0].zyh,
                                width: "500px",
                                height: "480px",
                                callBack: function (iframeId) {
                                    $.currentWindow(iframeId).AcceptClick(function () {
                                        $.loading(false);
                                        $.modalClose("OutAreaForm");
                                        getBedInitList(bqdm, 0);
                                    });
                                }
                            });
                        }
                    });
                }
            }, {
                name: '患者转区',
                onClick: function (row) {
                    $.modalConfirm("确定转区？", function (flag) {
                        if (flag) {
                            $.modalOpen({
                                id: "ChangeAreaForm",
                                title: "患者转区",
                                url: "/NurseManage/EntryRegistration/ChangeAreaForm?zyh=" + row[0].zyh,
                                width: "350px",
                                height: "300px",
                                callBack: function (iframeId) {
                                    top.frames[iframeId].SaveChangeArea();
                                    $.loading(false);
                                    $.modalClose("ChangeAreaForm");
                                    getPatInitList(bqdm);
                                    getBedInitList(bqdm, 0);
                                }
                            });
                        }
                    });
                }
            }, {
                name: '取消入区登记',
                onClick: function (row) {
                    $.modalConfirm("确定要取消入区登记吗？", function (flag) {
                        if (flag) {
                            $.ajax({
                                type: "GET",
                                url: "/EntryRegistration/PatCancelEntry?zyh=" + row[0].zyh,
                                dataType: "json",
                                success: function (ajaxresp) {
                                    if (ajaxresp.state == "success") {
                                        $.modalMsg('取消成功', 'success');
                                        getPatInitList(bqdm);
                                        getBedInitList(bqdm, 0);
                                    }
                                    else {
                                        $.modalAlert(ajaxresp.message, 'warning');
                                    }

                                }
                            });
                        }
                    });

                }
				}, {
					name: '住院床卡',
					onClick: function (row) {
						$.modalOpen({
							id: "InHospitalBedCard",
							title: "住院床卡",
							url: "/NurseManage/WardMaintenance/InHospitalBedCard?zyh=" + row[0].zyh,
							width: "500px",
							height: "480px",
							callBack: function (iframeId) {
								top.frames[iframeId].SavaBedCard();
								$.loading(false);
								$.modalClose("InHospitalBedCard");
								//window.open("/NurseManage/WardMaintenance/InHospitalBedCardPrint?zyh=" + row[0].zyh);
								window.open("http://59.80.30.184:16003/NurseManage/WardMaintenance/InHospitalBedCardPrint?zyh=" + row[0].zyh);
							}
						});
					}
				}
            ]
        });
    }
    //弹出入区时间和危重类型输入框
    function OpenRqdjForm() {
        $.modalOpen({
            id: "RqdjForm",
            title: "入区登记",
            url: "/NurseManage/EntryRegistration/EntryAreaFrom?ysgh="+ysgh+"&ysmc="+ysmc,
            width: "500px",
            height: "400px",
            callBack: function (iframeId) {
                var mbObj = top.frames[iframeId].submitForm();
                var enterData = {
                    rqrq: mbObj.rqrq,
                    ysgh: mbObj.ysgh,
                    ysmc: mbObj.ysmc,
                    wzjb: mbObj.wzjb,
                    cwCode: bedCode,
                    zyh: zyh,
                    qqlx: qqlx,
                    bqdm: bqdm,
                    lastcwCode: lastcwCode,
                    DeptCode: DeptCode
                };

                $.najax({
                    type: "POST",
                    url: "/EntryRegistration/EnterArea",
                    data: { enterArea: enterData },
                    dataType: "json",
                    loadingtext: "患者入区中，请稍后...",
                    success: function (ajaxresp) {
                        if (ajaxresp.state == "success") {
                            $.modalMsg('入区成功！', 'success');
                        }
                        else {
                            $.modalAlert(ajaxresp.message, 'warning');
                        }
                        getPatInitList(bqdm);
                        getBedInitList(bqdm, 0);
                    }
                });
                ysgh = null;
                ysmc = null;
                bedCode = null;
                zyh = null;
                eleDv = null;
            }
        });
    }

    //转床
    function TransferBed(eleBeDv) {
        $.modalConfirm("确定转床？", function (flag) {
            if (flag) {
                $.najax({
                    type: "POST",
                    url: "/EntryRegistration/ChangeBed",
                    data: { zyh: zyh, bedCode: bedCode, wardCode: bqdm },
                    dataType: "json",
                    loadingtext: "患者转床中，请稍后...",
                    success: function (ajaxresp) {
                        if (ajaxresp.state == "success") {
                            $.modalMsg('转床成功！', 'success');
                        }
                        else {
                            $.modalAlert(ajaxresp.message, 'warning');
                        }
                        getBedInitList(bqdm);
                    }
                });
            }

        });
    }
    function wardTree_onnodeclick(item) {
        bqdm = item.id;
        $("#li_turn").removeClass('active');
        $("#li_new").addClass('active');
        qqlx = "0";
        getPatInitList(bqdm);
        getBedInitList(bqdm, 0);
    }



    //病区列表

    







</script>
